From 93bb03d3875e4a07bf43737a873e5191c9b34f4d Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 30 Apr 2006 03:26:48 +0000 Subject: [PATCH] Don't divide by zero when computing speed. (this means you, saved Garmin tracks...) --- gpsbabel/route.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gpsbabel/route.c b/gpsbabel/route.c index df156b0a9..e34130244 100644 --- a/gpsbabel/route.c +++ b/gpsbabel/route.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2002 Robert Lipe, robertlipe@usa.net + Copyright (C) 2002-2006 Robert Lipe, robertlipe@usa.net This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -460,8 +460,11 @@ void track_recompute(const route_head *trk) first.creation_time = 0; QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) { + time_t timed; double tlat, tlon, plat, plon, dist; + this = (waypoint *)elem; + timed = this->creation_time - prev->creation_time; /* gcdist and headin want radians, not degrees */ tlat = RAD(this->latitude); tlon = RAD(this->longitude); @@ -470,8 +473,9 @@ void track_recompute(const route_head *trk) this->course = DEG(heading(plat, plon, tlat, tlon)); dist = radtometers(gcdist(plat, plon, tlat, tlon)); - this->speed = dist / - labs(this->creation_time - prev->creation_time); + if (timed) { + this->speed = dist / labs(timed); + } prev = this; } -- 2.30.2